<!--<table  width="75%" border="1">
  <tr> 
	<td><strong>Name</strong></td>
	<td><strong>Type</strong></td>
	<td><strong>Location</strong></td>
	<td><strong>Priority</strong></td>
	<td><strong>Due At</strong></td>
  </tr>
  <?php foreach($tasks as $task): ?>
	  <tr> 
		<td><?php echo link_to($task->getName(), 'task_update', $task); ?></td>
		<td><?php echo $task->getTaskType()->getName(); ?></td>
		<td><?php
				$location = $task->getTaskLocation();
				echo $location;				
			?></td>
		<td><?php echo $task->getTaskPriority()->getName(); ?></td>
		<td><?php echo $task->getDueString(); ?></td>
	  </tr>
	  	  
  <?php endforeach; ?>
</table>-->

<div style="width:350px;height:400px;overflow:scroll;float: right;background-image: url(bg_table.jpg);">
	<?php echo link_to('Add Task', '@task_new') ?>	
<table  border="1" style="">
<!--  <tr> 
	<td><div style="float: left; width:80%"><strong>Name</strong></div>&nbsp;&nbsp;
	<div style="float: right; width:20%"><strong>Type</strong></div><br />
	<div style="float: left; width:80%"><strong>Location</strong></div>&nbsp;&nbsp;
	<div style="float: right; width:20%"><strong>Priority</strong></div><br />
	<div><strong>Due At</strong></div></td>
  </tr>-->
  <?php foreach($tasks as $task): ?>
  <tr> 
	<td><div style="float: left; width:75%"><strong><?php echo link_to($task->getName(), 'task_update', $task); ?></strong></div>&nbsp;&nbsp;
	<div style="float: right; width:25%; color:red"><strong><?php echo $task->getTaskType()->getName(); ?></strong></div><br />
	<div style="float: left; width:75%"><strong><?php
				$location = $task->getTaskLocation();
				echo $location;				
			?></strong></div>&nbsp;&nbsp;
	<div style="float: right; width:25%"><strong><?php echo $task->getTaskPriority()->getName(); ?></strong></div><br />
	<div><strong><?php echo $task->getDueString(); ?></strong></div></td>
  </tr>

  <?php endforeach; ?>
</table>
</div>
	
<!----------------------Getting Google Map Key ------------------>	
<?php 
	$map_key  = sfConfig::get('app_google_map_api_key');
	//$map_key = "ABQIAAAAkPJNybUvHJpbDyvMbkJmfBSrlfdb58kYpUUC5OAsfxL8IJZkYxQ4pmjxp5iT2OxyPkWE6OznEf_Nlg";
		//ABQIAAAAkPJNybUvHJpbDyvMbkJmfBSrlfdb58kYpUUC5OAsfxL8IJZkYxQ4pmjxp5iT2OxyPkWE6OznEf_Nlg
	
	$src_str = "\"http://maps.google.com/maps?file=api&v=2&key=$map_key\"";
	?>
	<script src=<?php echo $src_str;?>
            type="text/javascript"></script>

    <script type="text/javascript">
    //<![CDATA[

    var iconBlue = new GIcon(); 
    iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
    iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

    var iconRed = new GIcon(); 
    iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
    iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconRed.iconSize = new GSize(12, 20);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["restaurant"] = iconBlue;
    customIcons["bar"] = iconRed;
    var index=0;
    var markerArray=[];
    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(-38.305261 ,146.413926), 11);
        for(var i=0;i<index;i++)
		{
			map.addOverlay(markerArray[i]);
		}
        
        GEvent.addListener(map, "click", function(overlay, point) 
        {
        	if(point)
        	{
	        	alert("Lat="+point.lat());
	        	alert("Long="+point.lng());
			}        	
		});		
      }
    }
	function addMarkerToMap(lat,lng,name,address,type,strHTML)
	{
		var point = new GLatLng(parseFloat(lat),parseFloat(lng));
	    var marker = createMarker(point, name, address, parseInt(type),strHTML);
	    markerArray[index++]=marker;	    
	}
    function createMarker(point, name, address, type,strHTML) {
      var marker = new GMarker(point, customIcons[type]);
      var html = "<b>" + name + "</b> <br/>" + address;
      GEvent.addListener(marker, 'click', function() {
      	  html=''+strHTML+html+'</a>';      	  
      	  marker.openInfoWindowHtml(strHTML);      
      });
      return marker;
    }    
    //]]>
    
  </script>
  <div id="map" style="width: 600px; height: 400px"></div>  
   <?php 
   	    foreach($tasks as $task): 
   	    $location = $task->getTaskLocation();
   		$lat = $location->getLatitude();
   		$lng = $location->getLongitude();
        $taskTitle = $task->getName();
        $priority = $task->getTaskPriority()->getName();//high, normal, low   	      	    
   	    $address=$location->getStreetName()." ".$location->getStreetName();
  		$landmark = $location->getLandmark();
   		if($landmark)
   		{
            $landMarkName = $landmark->getName();
            $address = $landmark->getAddress();
	   		$lat = $landmark->getLatitude();
	   		$lng = $landmark->getLongitude();
   		}   
   		if($priority=="high"||$priority=="HIGH")
   		{
   			$type=1;
   		}
   		else
   		{
   			$type=2;
   		}
   		if($lat && $lng)
   		{
			$strHTML= link_to($task->getName(), 'task_update', $task);	   		
	   		echo "<script type='text/javascript'> 			addMarkerToMap('".$lat."','".$lng."','".$taskTitle."','".$address."','".$type."','".$strHTML."');</script>";	
	   		
   		}
  		endforeach; 
    ?>  
      	 
      	 